//
//  UILabel+LineSpace.m
//  HuaRun2
//
//  Created by admin on 17/9/1.
//  Copyright © 2017年 Sunny. All rights reserved.
//

#import "UILabel+LineSpace.h"

@implementation UILabel (LineSpace)

//重新设置label 多行显示时的间距
- (void)resetLineSpaceWithHeight:(CGFloat)height str:(NSString *)str{
    // 设置为多行显示
    self.numberOfLines = 0;
    
    NSMutableParagraphStyle  *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    // 行间距设置为30
    [paragraphStyle  setLineSpacing:height];
    NSMutableAttributedString  *setString = [[NSMutableAttributedString alloc] initWithString:str];
    [setString  addAttribute:NSParagraphStyleAttributeName
                       value:paragraphStyle
                       range:NSMakeRange(0, [str length])];
    [setString addAttribute:NSFontAttributeName
                      value:kGeneralFontSize
                      range:NSMakeRange(0, str.length)];
    
    // 设置Label要显示的text
    [self  setAttributedText:setString];

}

//设置间距为5
- (void)resetLineSpaceHeight5WithStr:(NSString *)str {
    [self resetLineSpaceWithHeight:5 str:str];
}

@end
